package com.tuling.code.algorithm.loadbalance.complex;

import java.util.HashMap;
import java.util.Map;

public class ClientMain {
	public static void main(String[] args) {
		WeightedRoundRobinScheduling w = new WeightedRoundRobinScheduling();
		w.init();

		Map<String, Integer> countResult = new HashMap<String, Integer>();
		
		for(int i = 0; i <100 ; i++){
			Server s = w.getServer();
			
			String log = "ip = "+s.getIp()+" ; weight = "+s.getWeight();
			
			if(countResult.containsKey(log)){
				countResult.put(log,countResult.get(log)+1);
			} else {
				countResult.put(log, 1);
			}
			
			System.out.println(log);
		}

		
		countResult.forEach((k , v )-> System.out.println("服务器 "+k+" 请求次数： "+v));
	}
}
